﻿/**
 *
 * @title: Basic MVC Framework, AbstractController Class
 * @author: Robert Turrall (http://www.robertturrall.com)
 * @license: Creative Commons Attribution 3.0 (http://creativecommons.org/licenses/by/3.0/)
 *			In other words: Please feel free to use, change, redistribute and do what you want with 
 *			this code. Just keep the original header and author attribution intact. Follow the license
 *			link for more info.
 * @updated: 31/12/2008
 *
 * @version	1.0 
 */

package net.turrall.mvc {

	import net.turrall.mvc.*;
	import flash.events.EventDispatcher;
	import flash.events.Event;
	
	/**
	 * Basic Controller class in Model/View/Controller triad.
	 */
	public class AbstractController implements Controller {
		private var _model:EventDispatcher;
		private var _view:View;

		/**
		 * Constructor
		 *
		 * @param   m   The model this controller's view is observing.
		 */
		public function AbstractController(m:EventDispatcher) {
			// Set the model.
			setModel(m);
		}

		/**
		 * Sets the model for this controller.
		 */
		public function setModel(m:EventDispatcher):void {
			_model = m;
		}

		/**
		 * Returns the model for this controller.
		 */
		public function getModel():EventDispatcher {
			return _model;
		}

		/**
		 * Sets the view that this controller is servicing.
		 */
		public function setView(v:View):void {
			_view = v;
		}

		/**
		 * Returns this controller's view.
		 */
		public function getView():View {
			return _view;
		}
	}
}